package kamikaze.service;

import kamikaze.support.HttpMethod;
import kamikaze.support.Service;
import kamikaze.support.ServiceConfig;
import kamikaze.support.ServiceContext;
import kamikaze.support.UserSession.Type;

@ServiceConfig(path = "", method = HttpMethod.GET)
public class IndexPage implements Service {

	@Override
	public String serve(ServiceContext ctx) throws Exception {
		Type type = ctx.getUserSession().getType();

		if (type == null) {
			return "redirect:/login.jsp";
		}

		switch (ctx.getUserSession().getType()) {

		case Admin:
			return "redirect:/service/admin/home";
		case User:
			return "redirect:/service/user/home";
		default:
			return "redirect:/login.jsp";
		}

	}

}
